package com.topit.show.wxapi.common;

import org.springframework.util.StringUtils;
import com.bike.util.PageData;

public class WxUtil {
	
	private static AuthorizeService authorizeService=new AuthorizeService();
	
	public static String getOpenId(PageData pd) {
		String openid = null;
		if (!StringUtils.isEmpty(pd.getString("code"))) {
			openid= authorizeService.getOpenId(WxConstants.APPID, WxConstants.APPSECRET, pd.get("code").toString());
		}
		return openid;
	}

	public static String getRedirectUrl(String url) {
		String retUrl = WxConstants.SERVER_BASE_PATH + url;
		String redirectUrl = authorizeService.getOauthBaseUrl(WxConstants.APPID, "STATE", retUrl);
		return  redirectUrl;
	}

}
